package org.fao.geonet.services.param.branch;

import org.jdom.*;

import jeeves.constants.*;
import jeeves.interfaces.*;
import jeeves.resources.dbms.*;
import jeeves.server.*;
import jeeves.server.context.*;
import jeeves.utils.*;

import org.fao.geonet.constants.*;

//=============================================================================

/**
 * Removes a user from the system. It removes the relationship to a group too
 */

public class RemoveAreaCategory implements Service {
	// --------------------------------------------------------------------------
	// ---
	// --- Init
	// ---
	// --------------------------------------------------------------------------

	public void init(String appPath, ServiceConfig params) throws Exception {
	}

	// --------------------------------------------------------------------------
	// ---
	// --- Service
	// ---
	// --------------------------------------------------------------------------

public Element exec(Element params, ServiceContext context) throws Exception
	{
		String id_area = Util.getParam(params, "id_area");
		String id_category = Util.getParam(params, "id_category");
		
		Dbms dbms = (Dbms) context.getResourceManager().open (Geonet.Res.MAIN_DB);
		String sql = "DELETE FROM area_category " +
				"WHERE id_area=" + id_area+ " AND id_category = " + id_category;
		System.out.println( sql );
		dbms.execute ( sql );
		return new Element(Jeeves.Elem.RESPONSE);
	}}

// =============================================================================

